package com.studio701.carguard.controller;


import com.studio701.carguard.pojo.CarFault;
import com.studio701.carguard.pojo.RespBean;
import com.studio701.carguard.service.ICarFaultService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xjc
 * @since 2022-03-16
 */
@RestController
@RequestMapping("/car-fault")
public class CarFaultController {

    @Autowired
    ICarFaultService iCarFaultService;

    @ApiOperation("添加车辆系统信息")
    @PostMapping("/")
    public boolean insertCarFault(@RequestBody CarFault carFault){
        return iCarFaultService.save(carFault);
    }

    @ApiOperation("修改车辆系统信息")
    @PutMapping("/")
    RespBean updateCarFault(@RequestBody CarFault carFault){
        if (iCarFaultService.updateCarFaultByCarId(carFault)){
            return RespBean.success("更新成功");
        }else {
            return RespBean.error("更新失败");
        }
    }

    @ApiOperation("查找车俩系统信息")
    @GetMapping("/")
    CarFault getByCId(Integer id){
        return iCarFaultService.getByCId(id);
    }
}
